package com.pzhu.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CookieServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=utf-8");

		Cookie ck=new Cookie("mouse","thinkpad");
		Cookie ck1=new Cookie("keyboard","HW");

		ck.setMaxAge(3*24*3600);

		ck.setPath("/cookie/gc");

		resp.addCookie(ck);
		resp.addCookie(ck1);
		resp.getWriter().write("Cookie");
	}
}
